import axios from '../../utils/request';

/**
 * 模块名:系统用户
 */

// 创建
export function created(data: { name: string; password: number; roleIds: number[] }) {
  return axios.request({
    url: '/system-user',
    method: 'post',
    data,
  });
}

// 列表
export function list(params: { page: number; limit: number; name?: string }) {
  return axios.request({
    url: '/system-user',
    method: 'get',
    params,
  });
}

// 详情
export function detail(id: number) {
  return axios.request({
    url: '/system-user/' + id,
    method: 'get',
  });
}

// 更新
export function update(id: number, data: { name: string; password: number; roleIds: number[] }) {
  return axios.request({
    url: '/system-user/' + id,
    method: 'patch',
    data,
  });
}

// 删除
export function del(id: number) {
  return axios.request({
    url: '/system-user/' + id,
    method: 'delete',
  });
}

export default {
  created,
  list,
  detail,
  update,
  del,
};
